<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of verejne
 *
 * @author abc
 */

namespace application;

if (SECURE <> 'XLKDZJRKWOSLCMG') : throw new \Exception('Nemáte oprávnění přistupovat k souboru!', 761);
endif;

class verejne extends commonabstract {
    
    private $data = false;
    
    public function home($appparams) {
        if ($appparams <> $this->appparams) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        
        $this->data['webname'] = $this->appmodel->webname();
        $this->data['info'] = $this->appmodel->info();
        $this->data['footer'] = $this->appmodel->footer();
        $this->data['sidebar'] = $this->appmodel->sidebar();
        $this->data['contents'] = $this->appmodel->contents($this->app, $this->appaction, $appparams);
    }
    
    public function note($appparams) {
        if ($appparams <> $this->appparams) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        
        $this->data['webname'] = $this->appmodel->webname();
        $this->data['info'] = $this->appmodel->info();
        $this->data['footer'] = $this->appmodel->footer();
        $this->data['sidebar'] = $this->appmodel->sidebar();
        $this->data['contents'] = $this->appmodel->contents($this->app, $this->appaction, $appparams);
    }
    
    public function todo($appparams) {
        if ($appparams <> $this->appparams) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        
        $this->data['webname'] = $this->appmodel->webname();
        $this->data['info'] = $this->appmodel->info();
        $this->data['footer'] = $this->appmodel->footer();
        $this->data['sidebar'] = $this->appmodel->sidebar();
        $this->data['contents'] = $this->appmodel->contents($this->app, $this->appaction, $appparams);
    }
    
    public function manual($appparams) {
        if ($appparams <> $this->appparams) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        
        $this->data['webname'] = $this->appmodel->webname();
        $this->data['info'] = $this->appmodel->info();
        $this->data['footer'] = $this->appmodel->footer();
        $this->data['sidebar'] = $this->appmodel->sidebar();
        $this->data['contents'] = $this->appmodel->contents($this->app, $this->appaction, $appparams);
    }
    
    public function archive($appparams) {
        if ($appparams <> $this->appparams) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        
        $this->data['webname'] = $this->appmodel->webname();
        $this->data['info'] = $this->appmodel->info();
        $this->data['footer'] = $this->appmodel->footer();
        $this->data['sidebar'] = $this->appmodel->sidebar();
        $this->data['contents'] = $this->appmodel->contents($this->app, $this->appaction, $appparams);
    }
    
    public function upravit($appparams) {
        if ($appparams <> $this->appparams) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        
        if (!isset($appparams['ulozit'])) :
            $this->data['contents'] = $this->appmodel->returnid($this->app, $this->appaction, $appparams);
        else :
            if ($appparams['ulozit'] == true) :
                $args = array('titlefield' => FILTER_SANITIZE_ENCODED, 'textfield' => FILTER_SANITIZE_ENCODED);
                $postdata = \system\getpost::get($args);
                $this->appmodel->updateid($this->app, $this->appaction, $appparams, $postdata);
            endif;
            header('Location: '.WWW_PATH.'/verejne');
        endif;
        
        $this->data['webname'] = $this->appmodel->webname();
        $this->data['info'] = $this->appmodel->info();
        $this->data['footer'] = $this->appmodel->footer();
        $this->data['sidebar'] = $this->appmodel->sidebar();
        
        
        
//        $postdata = \system\getpost::gettest();
//        dump($postdata);
//        if ($appparams['ulozit'] == true) : 
//            $this->appmodel->updateid($appparams['id']);
        
        

        
 
    }
    
    public function getappdata($appaction) {
        if ($appaction <> $this->appaction) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        
        $this->$appaction($this->appparams);
        return $this->data;
    }
}
